package com.itheima.exception;

import com.itheima.common.response.ResponseResult;
import com.itheima.common.response.StatusCode;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @作者 itcast
 * @创建日期 2020/10/13 11:16
 **/
@RestControllerAdvice
public class ExceptionConfig {
    @ExceptionHandler(Exception.class)
//    @ResponseBody
    public ResponseResult exceptionHandle(Exception e){
        System.out.println(e.getCause());
        return ResponseResult.errorResult(StatusCode.SERVER_ERROR);
    }
}
